<template>
  <div>
    <el-dialog
      v-dialogDrag
      ref="dialog"
      :close-on-click-modal="false"
      :visible.sync="editDialog"
      :before-close="cancel"
      :append-to-body="true"
      title="编辑客户名称"
      width="30%"
      @open="init"
    >
      <el-form
        ref="Form"
        :inline="true"
        :model="userInfo"
        :rules="rules"
        size="mini"
        label-width="95px">
        <el-form-item prop="userName" label="客户名称">
          <el-input v-model="userInfo.userName" clearable/>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer" style="text-align:center;">
        <el-button type="text">
          <i class="el-icon-search magnifier" />
        </el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
  <!-- <el-dialog :visible.sync="editDialog" :title="编辑客户名称" :before-close="cancel" width="40%" @open="init">
    <el-form
      ref="Form"
      :inline="true"
      :model="userInfo"
      :rules="releaseRules"
      size="mini"
      label-width="95px">
      <el-form-item prop="userName" label="客户名称">
        <el-input v-model="userInfo.userName" clearable/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align:center;">
      <el-button type="text">
        <i class="el-icon-search magnifier" />
      </el-button>
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </div>
  </el-dialog> -->
</template>
<script>
import rSelect from '@/components/Select/Select'
import BaseTable from '@/components/BaseTable'
import filtercode from '@/components/Checkbox/filtercode'
import { editUserName } from '@/api/vehicle/custBiz.js'
import formMixins from '@/mixins/formMixins'
import moment from 'moment'
// import _ from 'lodash'

export default {
  name: 'CustBizIndex',
  components: {
    BaseTable,
    rSelect,
    filtercode,
    moment
  },

  mixins: [formMixins],
  props: {
    editDialog: {
      type: Boolean,
      default: false
    },
    user: {
      type: Object,
      // eslint-disable-next-line vue/require-valid-default-prop
      default: {}
    }
  },
  data() {
    return {
      rules: {
        userName: [{ trigger: 'blur', required: true, message: '用户名称不能为空' }]
      },
      userInfo: {
        userName: '',
        userId: ''
      }
    }
  },

  mounted() {
  },
  methods: {
    init() {
      this.userInfo = this.user
    },

    confirm() {
      this.$refs['Form'].validate(valid => {
        if (valid) {
          editUserName(this.userInfo).then(res => {
            this.$message({
              type: 'success',
              message: '客户名称保存成功!'
            })
            this.cancel()
          })
        }
      })
    },

    cancel() {
      this.userInfo = {
        userName: '',
        userId: ''
      }
      // this.editDialog = false
      this.$emit('editClose')
    }
  }
}
</script>

<style scoped>

</style>
